<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Video
 *
 * @property int $id
 * @property int|null $type_id 分类id
 * @property string|null $type_name 分类名称
 * @property string|null $name 影视名称
 * @property string|null $img 图片
 * @property string|null $desc 影视描述
 * @property string|null $director 影视导演
 * @property string|null $performer 主演
 * @property string|null $url 影视地址
 * @property int|null $num 观看人数
 * @property int|null $fraction 分数
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property int|null $isdelete -1冻结0删除1正常
 * @property int|null $param 其他参数
 * @property-read mixed $avatar
 * @method static \Illuminate\Database\Eloquent\Builder|Video newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Video newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Video query()
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereDesc($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereDirector($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereFraction($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereImg($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereIsdelete($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereNum($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereParam($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video wherePerformer($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereTypeId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereTypeName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Video whereUrl($value)
 * @mixin \Eloquent
 * @property-read \App\Models\Type|null $video_type
 */
class Video extends Model
{
    //
    protected $table = 'video';

    public function setCreatedAtAttribute($value)
    {
        $this->attributes['created_at'] = strtotime($value);
    }
    public function setUpdatedAtAttribute($value)
    {
        $this->attributes['updated_at'] = strtotime($value);
    }
    public function getAvatarAttribute($value)
    {
        return $value;
    }

    public function video_type()
    {
        return $this->hasOne('App\Models\Type','id','type_id');
    }

}
